package com.example.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.example.business.entity.SysUser;
import com.example.business.mapper.SysUserMapper;
import com.example.business.service.SysUserService;
import org.springframework.cache.annotation.*;
import java.io.Serializable;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.cache.annotation.CacheConfig;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiong
 * @since 2024-01-27
 */
@Service
@Transactional
@CacheConfig(cacheNames = "SysUserServiceImpl")
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Cacheable(cacheNames = "sysuser",key = "#id")
    @Override
    public SysUser getById(Serializable id){
        return super.getById(id);
    }

    @CacheEvict(cacheNames = "sysuser", key = "#id")
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

    @CacheEvict(cacheNames = "sysuser", key = "#sysuser.id")
    @Override
    public boolean updateById(SysUser sysuser) {
        return super.updateById(sysuser);
    }

    @CachePut(cacheNames = "sysuser", key = "#sysuser.id")
    public SysUser saveSysUser(SysUser sysuser){
        super.save(sysuser);
        return sysuser;
    }

    @CacheEvict(cacheNames = "sysuser", key = "#sysuser.id")
    public SysUser updateSysUserById(SysUser sysuser){
        super.updateById(sysuser);
        return sysuser;
    }
}
